package org.dataone.dataUsage;

import java.util.ArrayList;

import com.ibm.icu.text.SimpleDateFormat;
import com.ibm.icu.util.Calendar;

/** This class is to generate separate date format for data visualization */
public class DateList {
	private ArrayList<String> datelist;

	public ArrayList<String> getDatelist() {
		return datelist;
	}
	/**
	 * This construction is to generate a date list for visualization Returns an
	 * ArrayList of special date format
	 * 
	 * @param timespan
	 *            for different time span,the date list is not same.
	 */
	public DateList(int timespan) {
		ArrayList<String> datelist = new ArrayList<String>();
		Calendar c = Calendar.getInstance();
		SimpleDateFormat sdf = new SimpleDateFormat("MM/YYYY");
		c.add(c.MONTH, -timespan);
		for (int i = 0; i < timespan; i = i + timespan / 4) {
			datelist.add("\"" + sdf.format(c.getTime()).substring(0, 2) + "/"
					+ sdf.format(c.getTime()).substring(5, 7) + "\"");
			for (int j = 1; j < timespan / 4; j++) {
				datelist.add("\"\"");
			}
			c.add(c.MONTH, timespan / 4);
		}
		this.datelist = datelist;
	}

}
